<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    {$LOAD_STYLE.top|raw}
</head>
	<body class="pear-container">
		<div class="layui-card">
			<div class="layui-card-body">
				<form class="layui-form layui-form-pane" action="">
					<div class="layui-form-item">
                           
               <div class="layui-form-item layui-inline">
                   <label class="layui-form-label">商家名称</label>
                   <div class="layui-input-inline">
                       <input type="text" name="name" placeholder="" class="layui-input">
                   </div>
               </div>   
               <div class="layui-form-item layui-inline">
                   <label class="layui-form-label">公司名</label>
                   <div class="layui-input-inline">
                       <input type="text" name="company" placeholder="" class="layui-input">
                   </div>
               </div>   
               <div class="layui-form-item layui-inline">
                   <label class="layui-form-label">电话号码</label>
                   <div class="layui-input-inline">
                       <input type="text" name="phone" placeholder="" class="layui-input">
                   </div>
               </div>   
               <div class="layui-form-item layui-inline">
                   <label class="layui-form-label">微信号</label>
                   <div class="layui-input-inline">
                       <input type="text" name="weixin" placeholder="" class="layui-input">
                   </div>
               </div>
                        <div class="layui-form-item layui-inline">
                       <button class="pear-btn pear-btn-md pear-btn-primary" lay-submit lay-filter="query">
                           <i class="layui-icon layui-icon-search"></i>
                           查询
                       </button>
                       <button type="reset" class="pear-btn pear-btn-md">
                           <i class="layui-icon layui-icon-refresh"></i>
                           重置
                       </button>
                       </div>
                    </div>
				</form>
			</div>
		</div>
		<div class="layui-card">
			<div class="layui-card-body">
				<table id="dataTable" lay-filter="dataTable"></table>
			</div>
		</div>

		<script type="text/html" id="toolbar">
			<button class="pear-btn pear-btn-primary pear-btn-md" lay-event="add">
		        <i class="layui-icon layui-icon-add-1"></i>
		        新增
			</button>
			<button class="pear-btn pear-btn-danger pear-btn-md" lay-event="batchRemove">
		        <i class="layui-icon layui-icon-delete"></i>
		        删除
		    </button>
            <button class="pear-btn pear-btn-md" lay-event="recycle">
		        <i class="layui-icon layui-icon-delete"></i>
		        回收站
		    </button>
		</script>

        
	   <script type="text/html" id="status">
		   <input type="checkbox" name="status" value="{{d.id}}" lay-skin="switch" lay-text="启用|禁用" lay-filter="status" {{# if(d.status==1){ }} checked {{# } }}>
	   </script>
	   
	   <script type="text/html" id="exp_time">
	       {{# if(d.exp_time==="0000-00-00"){ }}
		   
		   {{# }else{ }}
		   {{d.exp_time}}
		   {{# } }}
	   </script>

		<script type="text/html" id="options">
			<button class="pear-btn pear-btn-primary pear-btn-sm" lay-event="edit"><i class="layui-icon layui-icon-edit"></i></button>
			<button class="pear-btn pear-btn-warming pear-btn-sm" lay-event="setid"><i class="layui-icon layui-icon-link"></i></button>
		    <button class="pear-btn pear-btn-danger pear-btn-sm" lay-event="remove"><i class="layui-icon layui-icon-delete"></i></button>
		</script>
        <script>
        layui.use(['jquery','common','mycomm','table'], function() {
            let $ = layui.jquery;
			let common = layui.common;
			let mycomm = layui.mycomm;
			let table = layui.table;
			let $table_name = "dataTable";
            let MODULE_PATH = "{$MODULE_PATH}";
            
            let cols = [
                [{
                        type: 'checkbox'
                    },{
                       field: "id",
                       title: "ID",
                       unresize: "true",
                       align: "center",
					   width: 60,
                   }, {
                       field: "name",
                       title: "商家名称",
                       unresize: "true",
                       align: "center",
					   width: 130,
                   }, {
                       field: "company",
                       title: "公司名",
                       unresize: "true",
                       align: "center",
					   width: 200,
                   }, {
                       field: "contact",
                       title: "联络人",
                       unresize: "true",
                       align: "center",
					   width: 100,
                   }, {
                       field: "phone",
                       title: "电话号码",
                       unresize: "true",
                       align: "center",
					   width: 120,
                   }, {
                       field: "weixin",
                       title: "微信号",
                       unresize: "true",
                       align: "center",
					   width: 100,
                   }, {
                       field: "province",
                       title: "省份",
                       unresize: "true",
                       align: "center",
					   width: 80,
                   }, {
                       field: "city",
                       title: "城市",
                       unresize: "true",
                       align: "center",
					   width: 80,
                   }, {
                       field: "exp_time",
                       title: "到期时间",
                       unresize: "true",
                       align: "center",
					   templet:"#exp_time",
					   width: 120,
                   }, {
                       field: "create_time",
                       title: "添加时间",
                       unresize: "true",
                       align: "center",
					   width: 160,
                   }, {
                       field: "status",
                       title: "状态",
                       unresize: "true",
                       align: "center",
                       templet:"#status",
					   width: 100,
                   }, {
                        title: '操作',
                        toolbar: '#options',
                        unresize: true,
                        align: 'center',
                    }
                ]
            ]
			
			mycomm.tableInit('{$controller_title}',MODULE_PATH,cols);
			
			mycomm.tableTool('{$controller_title}',MODULE_PATH,$table_name,function(obj){
				if(obj.event === "setid"){
					var url = MODULE_PATH + "setID";
					mycomm.ajax(url,{id:obj.data.id},"GET",function(res){
						Alert(res.msg,'success',2);
					},{},function(){
						
					});
				}
			});
        })
    </script>
	{$LOAD_STYLE.bottom|raw}
	</body>
</html>
